//
//  ByViewGoodsClassify.m
//  mijifen_ios
//
//  Created by mc on 2017/11/2.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByViewGoodsClassify.h"

// view
#import "ByViewGoodsDefine.h"
#import "ByViewGoodsClassdifyInfo.h"

@implementation ByViewGoodsClassify
{
    UIView              *_lineView1;
    UILabel             *_classHeaderLabel;
    UIView              *_lineView2;
    
    UIView              *_oneLevelView;
    UILabel             *_oneLabel;
    UILabel             *_oneLeftLabel;
    UIImageView         *_oneRightImg;
    
    UIView              *_secLevelView;
    UILabel             *_secLabel;
    UILabel             *_secLeftLabel;
    UIImageView         *_secRightImg;

}
- (instancetype)init{
    if (self = [super init]) {
        [self createViews];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)createViews{
    _lineView1 = [[UIView alloc] init];
    [self addSubview:_lineView1];
    _lineView1.backgroundColor = [UIColor colorWithWhite:0.90 alpha:1];
    
    _classHeaderLabel = [[UILabel alloc] init];
    [self addSubview:_classHeaderLabel];
    
    _lineView2 = [[UIView alloc] init];
    [self addSubview:_lineView2];
    _lineView2.backgroundColor = [UIColor colorWithWhite:0.90 alpha:1];
    
    _oneLevelView = [[UIView alloc] init];
    [self addSubview:_oneLevelView];
    _oneLevelView.backgroundColor = [UIColor whiteColor];
    
    _oneLeftLabel = [[UILabel alloc] init];
    [_oneLevelView addSubview:_oneLeftLabel];
    
    _oneLabel = [[UILabel alloc] init];
    [_oneLevelView addSubview:_oneLabel];
    
    _oneRightImg = [[UIImageView alloc] init];
    [_oneLevelView addSubview:_oneRightImg];
    
    _secLevelView = [[UIView alloc] init];
    [self addSubview:_secLevelView];
    
    _secLabel = [[UILabel alloc] init];
    [_secLevelView addSubview:_secLabel];
    
    _secLeftLabel = [[UILabel alloc] init];
    [_secLevelView addSubview:_secLeftLabel];
    
    _secRightImg = [[UIImageView alloc] init];
    [_secLevelView addSubview:_secRightImg];
    
   
    
}

- (void)setModel:(ByModelGoodsClassify *)model{
    _model = model;
    
    // 商品分类
    CGFloat width = [@"商品分类" getSizeOfString:16].width + 20;
    [_classHeaderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset((SCREEN_WIDTH - width) / 2);
        make.top.equalTo(self.mas_top).offset(10);
        make.size.mas_equalTo(CGSizeMake(width, 20));
    }];
    _classHeaderLabel.text = @"商品分类";
    _classHeaderLabel.font = FONT(14);
    _classHeaderLabel.textColor = [UIColor darkGrayColor];
    _classHeaderLabel.textAlignment = NSTextAlignmentCenter;
    
    [_lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_classHeaderLabel.mas_left);
        make.top.equalTo(_classHeaderLabel.mas_top).offset(10);
        make.size.mas_equalTo(CGSizeMake(50, 1));
    }];
    
    [_lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_classHeaderLabel.mas_right);
        make.top.equalTo(_lineView1.mas_top);
        make.size.mas_equalTo(CGSizeMake(50, 1));
    }];
    
    // 一级分类
    [_oneLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.top.equalTo(_classHeaderLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 50));
    }];
    
    width = [@"一级分类：" getSizeOfString:16].width + 5;
    [_oneLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_oneLevelView.mas_left).offset(10);
        make.top.equalTo(_oneLevelView.mas_top).offset(10);
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    _oneLeftLabel.text = @"一级分类:";
    _oneLeftLabel.font = FONT(16);
    
    [_oneRightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_oneLevelView.mas_right).offset(-10);
        make.top.equalTo(_oneLevelView.mas_top).offset(10);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    _oneRightImg.backgroundColor = [UIColor redColor];
    
    [_oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_oneLeftLabel.mas_right);
        make.right.equalTo(_oneRightImg.mas_left);
        make.top.equalTo(_oneLeftLabel.mas_top);
        make.bottom.equalTo(_oneLevelView.mas_bottom).offset(-10);
    }];
    _oneLabel.text = @"请选择分类";
    _oneLabel.font = FONT(16);
    
    // 二级分类
    [_secLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.top.equalTo(_oneLevelView.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 50));
    }];
    _secLevelView.backgroundColor = [UIColor whiteColor];
    
    width = [@"二级分类：" getSizeOfString:16].width + 5;
    [_secLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_secLevelView.mas_left).offset(10);
        make.top.equalTo(_secLevelView.mas_top).offset(10);
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    _secLeftLabel.text = @"二级分类:";
    _secLeftLabel.font = FONT(16);
    
    [_secRightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_secLevelView.mas_right).offset(-10);
        make.top.equalTo(_secLeftLabel.mas_top);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    _secRightImg.backgroundColor = [UIColor redColor];
    
    [_secLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_secLeftLabel.mas_right);
        make.right.equalTo(_secRightImg.mas_left);
        make.top.equalTo(_secLeftLabel.mas_top);
        make.bottom.equalTo(_secLevelView.mas_bottom).offset(-10);
    }];
    _secLabel.text = @"请选择分类";
    _secLabel.font = FONT(16);
    
}

- (void)clickAction{
//    ByViewGoodsClassdifyInfo *infoView = [[ByViewGoodsClassdifyInfo alloc] init];
//    if (_model) {
//        <#statements#>
//    }
}

@end
